package bbstorespringmvc.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import bbstorespringmvc.model.Book;
import bbstorespringmvc.repository.BookRepository;

@Controller
public class BookListController {

	@Autowired BookRepository bookRepository;

	@RequestMapping("/booklist")
	public ModelAndView showBookList(){
		ModelAndView mv = new ModelAndView("booklist");   // JSP
		List<Book> list = bookRepository.findAllByTitle();
		mv.addObject("bookList", list); 
		return mv;
	}
}
